<template>
  <div class="WorkingSchedule" v-loading="loading">
    <el-form ref="form" :model="form" label-position="top" class="myform">
      <div>
        <el-form-item label="投诉编号/订单号/商品编号:" class="myform-item">
          <el-input
            v-model="form.number"
            placeholder="投诉编号/订单号/商品编号"
            @keyup.enter.native="onSearch"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="申请时间:" class="myform-item">
          <el-date-picker
            value-format="yyyy-MM-dd"
            v-model="form.create_time"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="投诉原因:" class="myform-item">
          <el-select v-model="form.complaint_reason" placeholder="请选择">
            <el-option label="不限" value=""> </el-option>
            <el-option
              v-for="item in ComplaintReason"
              :key="item.complaint_reason"
              :label="item.complaint_reason"
              :value="item.complaint_reason"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="投诉状态:" class="myform-item">
          <el-select v-model="form.complaint_status" placeholder="请选择">
            <el-option label="不限" value=""> </el-option>
            <el-option
              v-for="item in ComplaintStatus"
              :key="item.complaint_status"
              :label="item.complaint_status"
              :value="item.complaint_status"
            >
            </el-option>
          </el-select>
        </el-form-item>
      </div>
      <div>
        <el-form-item style="margin-top: 50px">
          <el-button type="primary" @click="onSearch">查询</el-button>
          <!-- <el-button type="primary">导出</el-button>
          <el-button type="primary">上传文件</el-button> -->
        </el-form-item>
      </div>
    </el-form>
    <el-table :data="tableData" style="width: 100%" border>
      <el-table-column label="商品信息" align="center" prop="product_name">
      </el-table-column>
      <el-table-column label="投诉编号" align="center" prop="complaint_no">
      </el-table-column>
      <el-table-column label="订单号" align="center" prop="order_no">
      </el-table-column>
      <el-table-column label="申请时间" align="center" prop="create_time">
      </el-table-column>
      <el-table-column label="投诉人" align="center" prop="wwid">
      </el-table-column>
      <el-table-column
        label="赔付金额"
        align="center"
        prop="claim_demage_price"
      >
      </el-table-column>
      <el-table-column label="投诉原因" align="center" prop="complaint_reason">
      </el-table-column>
      <!-- <el-table-column label="投诉平台" align="center" prop="passrate">
      </el-table-column> -->
      <el-table-column label="投诉状态" align="center" prop="complaint_status">
      </el-table-column>
    </el-table>
    <pagination
      :form="form"
      :total="total"
      @paginationPostOrderTaskList="postAdminOperateComplaint_list"
    />
  </div>
</template>

<script>
import {
  postAdminOperateComplaint_list,
  postAdminOperateComplaint_reason,
  postAdminOperateComplaint_status,
} from "@/api";
import pagination from "@/components/pagination.vue";
export default {
  components: { pagination },
  data() {
    return {
      loading: false,
      form: {
        number: "",
        create_time: "",
        complaint_reason: "",
        complaint_status: "",
        page: 1,
        size: 10,
      },
      tableData: [],
      total: 1,
      ComplaintReason: [],
      ComplaintStatus: [],
    };
  },
  activated() {
    let form = this.form;
    this.postAdminOperateComplaint_list(form);
    this.postAdminOperateComplaint_reason();
    this.postAdminOperateComplaint_status();
  },
  methods: {
    // 投诉原因
    postAdminOperateComplaint_reason() {
      postAdminOperateComplaint_reason().then((res) => {
        this.ComplaintReason = res.data;
      });
    },
    // 投诉状态
    postAdminOperateComplaint_status() {
      postAdminOperateComplaint_status().then((res) => {
        this.ComplaintStatus = res.data;
      });
    },
    // qc列表
    async postAdminOperateComplaint_list(data) {
      this.loading = true;
      this.form = data;
      let form = JSON.parse(JSON.stringify(this.form));
      if (form.create_time) {
        form.create_time = `${form.create_time[0]}/${form.create_time[1]}`;
      }
      postAdminOperateComplaint_list(form)
        .then((res) => {
          this.loading = false;
          console.log("qc列表", res);
          this.tableData = res.data;
          this.total = Number(res.total);
        })
        .catch((err) => {
          this.loading = false;
        });
    },
    // 搜索
    onSearch() {
      this.form.page = 1;
      this.form.size = 10;
      this.postAdminOperateComplaint_list(this.form);
    },
  },
};
</script>

<style lang="scss" scoped>
.myform {
  display: flex;
  justify-content: space-between;
  > div {
    display: flex;
  }
  &-item {
    margin-right: 10px;
  }
}
.WorkingSchedule {
  background: #ffff;
  padding: 20px;
  border-radius: 2px;
  @include boxShadow;
}
</style>
